<template>
	<!-- 历史订单 -->
	<view class="bigbox">
		<u-empty text="订单为空" marginTop="100" v-if="!data.length"></u-empty>
		<view class="order-item pl20 pr20 pt32 pb32 mb20" v-for="(item,index) in data" :key="index">
			<!-- 上面的盒子 -->
			<view class="flex row-between">
				<!-- 左侧的盒子 -->
				<view class="box-left">
					<view class="box-tit">{{item.name}}</view>
					<view class="mt40">
						<text class="box-txt">意向岗位：</text> <text class="box-txt2">{{item.intended_position}}</text>
					</view>
					<view class="mt26">
						<text class="box-txt">意向薪酬：</text> <text
							class="box-txt2">{{item.intended_salary||0}}-{{item.intended_salary_end||0}}</text>
					</view>
				</view>
				<!-- 左侧的盒子 -->
				<!-- 右侧的盒子 -->
				<view class="box-right">
					<view class="flex row-right">
						<view class="box-tit">{{item.status_text}}</view>
					</view>
					<view class="mt40">
						<text class="box-txt">工作区域：</text> <text class="box-txt2">{{item.intended_work_area}}</text>
					</view>
					<view class="mt26">
						<text class="box-txt">求职状态：</text> <text class="box-txt2">{{item.job_status}}</text>
					</view>
				</view>
				<!-- 右侧的盒子 -->
			</view>
			<!-- /上面的盒子 -->

			<!-- 下面的盒子 -->
			<view class="flex mt48 row-between color-zs" v-if="item.status_text!='已取消'">
				<view class="w186 h54 orderBtn" @tap="$jump('/pages/home/recruit/vipJob/vipJob?state=修改&index='+index+'&type=1')" v-if="item.status_text!='已入职'">
					修改订单</view>
				<view class="w186 h54 orderBtn" @tap="recruitsVipCancel(item.id)" v-if="item.status_text!='已入职'">取消订单</view>
				<view class="w186 h54 orderBtn bg-zs color-fff" @tap="recruitsVipStatus(item.id)" v-if="item.status_text!='已入职'">确认入职</view>
			</view>
			<!-- 下面的盒子 -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: '',
				page: 1,
				type: ''
			};
		},
		onLoad(e) {
			if (e.type) {
				this.type = e.type
			}
		},
		onReachBottom() {
			this.page++
			this.recruitsVipList()
		},
		onShow() {
			this.recruitsVipList()
		},
		methods: {
			recruitsVipList() { //VIP岗位列表
				let data = {
					page: 1,
					size: this.page * 10
				}
				let api
				if (this.type == 1) {
					api = 'recruitsVipList'
				} else if (this.type == 3) {
					api = 'internshipVipList'
				}
				this.$api[api](data).then(res => {
					this.data = res.data
				})
			},
			recruitsVipCancel(id) { //取消订单
				let api
				if (this.type == 1) {
					api = 'recruitsVipCancel'
				} else if (this.type == 3) {
					api = 'internshipVipCancel'
				}
				let that = this
				uni.showModal({
					title: "取消订单",
					content: "确定要取消吗？",
					success(res) {
						if (res.confirm) {
							that.$api[api]({
								id
							}).then(res1 => {
								that.$msg(res.msg)
								that.recruitsVipList()
							})
						}
					}
				})
			},
			recruitsVipStatus(id) { //确认入职
				let api
				if (this.type == 1) {
					api = 'recruitsVipCancel'
				} else if (this.type == 3) {
					api = 'inrecruitsVipStatus'
				}
				let that = this
				uni.showModal({
					title: "确认入职",
					content: "确认入职吗？",
					success(res) {
						if (res.confirm) {
							that.$api.recruitsVipStatus({
								id
							}).then(res1 => {
								that.$msg(res.msg)
								that.recruitsVipList()
							}).catch(err=>{
								that.$msg('该岗位不存在,请勿重复操作')
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.order-item {
		background-color: #FFFFFF;
		box-shadow: 0px 6rpx 20rpx 0px #E8EAEF;
		border-radius: 14rpx;

		.box-tit {
			font-size: 30rpx;
			color: #0C162E;
		}

		.box-txt,
		.box-txt2 {
			font-size: 21rpx;
			font-weight: 500;
			color: #6D788B;
		}

		.box-txt2 {
			color: #1D2538;
		}
	}

	.orderBtn {
		text-align: center;
		line-height: 52rpx;
		border: 2rpx solid #1385FF;
		border-radius: 10rpx;
		font-weight: 500;
		// color: #1385FF;
	}
</style>
